/*
 * @Author: your name
 * @Date: 2022-01-11 20:32:00
 * @LastEditTime: 2022-01-11 20:32:00
 * @LastEditors: your name
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \创作平台\admin\src\utils\Breadcrumb.js
 */
const Breadcrumb = (data, path) => {
    if (path === data[0].path) return [data[0]];
    let result = [];
    result.unshift(data[0]);
    const index = data.findIndex((item) => item.path === path);
    if (index !== -1) {
        result.push(data[index]);
    } else {
        data.forEach((item) => {
            if (item.children) {
                result.push(item);
                item.children.forEach((val, index) => {
                    if (val.path === path && index !== 0) {
                        result.push(val);
                    }
                });
            }
        });
    }
    return result;
};
export default Breadcrumb;